package com.gary.demo.config;

import com.gary.demo.common.exception.BizException;
import com.gary.demo.common.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class ExceptionAdvice {


    @ExceptionHandler(RuntimeException.class)
    public Result handle(RuntimeException e) {
        return Result.fail(e.getMessage());
    }

    @ExceptionHandler(BizException.class)
    public Result handle(BizException e) {
        return Result.fail(e.getErrorMsg());
    }
}
